<?php

include '../controllers/getMachine.php';
include '../controllers/getMachineList.php';
date_default_timezone_set("PRC");
$exam = $_REQUEST['exam'];
$readMachines = getMachineBaseInfoByExamAndType($exam, 1);
$logicMachines = getMachineBaseInfoByExamAndType($exam, 2);
$writeMachines = getMachineBaseInfoByExamAndType($exam, 3);
$mathMachines = getMachineBaseInfoByExamAndType($exam, 4);
$machineList = getMachineListByExam($exam);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>推荐机经</title>
<script src="../js/machinemanager.js"></script>
</head>
<body onLoad="javascript:document.reset()">
<a href="javascript:history.back(-1)">返回</a>
<hr />
<table border='2' rules='rows' align="center" cellpadding='8%'>
	<thead>
		<tr align="center">
			<th colspan="2">
			<h1><?php 
			if ($exam == 1) {
				echo "推荐的GMAT机经";
			}
			elseif ($exam == 2) {
				echo "推荐的GRE机经";
			}
			?></h1>
			</th>
		</tr>
	</thead>
	<tr>
		<td colspan="2" style='background-color: gray; height: 30px;'></td>
	</tr>
	<tr align="left">
		<td>标题</td>
		<td align="left">
		<input type="text" size="100" id="listTitle"
			value="<?php echo $machineList->title;?>"></input> <input
			type="button" value="修改推荐说明"
			onclick="updateListTitle(<?php echo $machineList->mlId;?>);"></input>
		</td>
	</tr>
	<tr>
		<td align='center' colspan="2" style='background-color: gray; height: 30px;'><h3>阅读</h3></td>
	</tr>
	<tr align="left">
		<td colspan="2">
		<table border='2' rules='rows' cellpadding='8%' align='center'
			width='100%'>
			<tr>
				<th width="12%">机经ID</th>
				<th width="50%">标题</th>
				<th width="20%">时间说明</th>
				<th width="18%">操作</th>
			</tr>
			<?php
			$machineCount = count($readMachines);
			for ($i = 0; $i < $machineCount; $i++) {
					
				$machine = $readMachines[$i];
				$machineId = $machine->machineId;
				$title = $machine->title;
				$updateInfo = $machine->update;
				$timestamp = $machine->timestamp;
				$content = $machine->content;
				$formatTime = date("y-m-d h:i:s",$timestamp);
				echo "<tr align='left'><td>$machineId</td><td>$title</td><td>$updateInfo</td>";
				echo "<td><input type='button' value='修改' onclick='gotoUpdateMachine($machineId);'></input>";
				echo "<input type='button' value='删除' onclick='deleteMachine($machineId);'></input><td>";
				echo "</tr>";
			}
			?>
		</table>
		</td>
	</tr><tr>
		<td align='center' colspan="2" style='background-color: gray; height: 30px;'><h3>逻辑</h3></td>
	</tr>
	<tr align="left">
		<td colspan="2">
		<table border='2' rules='rows' cellpadding='8%' align='center'
			width='100%'>
			<tr>
				<th width="12%">机经ID</th>
				<th width="50%">标题</th>
				<th width="20%">时间说明</th>
				<th width="18%">操作</th>
			</tr>
			<?php
			$machineCount = count($logicMachines);
			for ($i = 0; $i < $machineCount; $i++) {
					
				$machine = $logicMachines[$i];
				$machineId = $machine->machineId;
				$title = $machine->title;
				$updateInfo = $machine->update;
				$timestamp = $machine->timestamp;
				$formatTime = date("y-m-d h:i:s",$timestamp);
				echo "<tr align='left'><td>$machineId</td><td>$title</td><td>$updateInfo</td>";
				echo "<td><input type='button' value='修改' onclick='gotoUpdateMachine($machineId);'></input>";
				echo "<input type='button' value='删除' onclick='deleteMachine($machineId);'></input><td>";
				echo "</tr>";
			}
			?>
		</table>
		</td>
	</tr><tr>
		<td align='center' colspan="2" style='background-color: gray; height: 30px;'><h3>写作</h3></td>
	</tr>
	<tr align="left">
		<td colspan="2">
		<table border='2' rules='rows' cellpadding='8%' align='center'
			width='100%'>
			<tr>
				<th width="12%">机经ID</th>
				<th width="50%">标题</th>
				<th width="20%">时间说明</th>
				<th width="18%">操作</th>
			</tr>
			<?php
			$machineCount = count($writeMachines);
			for ($i = 0; $i < $machineCount; $i++) {
					
				$machine = $writeMachines[$i];
				$machineId = $machine->machineId;
				$title = $machine->title;
				$updateInfo = $machine->update;
				$timestamp = $machine->timestamp;
				$formatTime = date("y-m-d h:i:s",$timestamp);
				echo "<tr align='left'><td>$machineId</td><td>$title</td><td>$updateInfo</td>";
				echo "<td><input type='button' value='修改' onclick='gotoUpdateMachine($machineId);'></input>";
				echo "<input type='button' value='删除' onclick='deleteMachine($machineId);'></input><td>";
				echo "</tr>";
			}
			?>
		</table>
		</td>
	</tr><tr>
		<td align='center' colspan="2" style='background-color: gray; height: 30px;'><h3>数学</h3></td>
	</tr>
	<tr align="left">
		<td colspan="2">
		<table border='2' rules='rows' cellpadding='8%' align='center'
			width='100%'>
			<tr>
				<th width="12%">机经ID</th>
				<th width="50%">标题</th>
				<th width="20%">时间说明</th>
				<th width="18%">操作</th>
			</tr>
			<?php
			$machineCount = count($mathMachines);
			for ($i = 0; $i < $machineCount; $i++) {
					
				$machine = $mathMachines[$i];
				$machineId = $machine->machineId;
				$title = $machine->title;
				$updateInfo = $machine->update;
				$timestamp = $machine->timestamp;
				$formatTime = date("y-m-d h:i:s",$timestamp);
				echo "<tr align='left'><td>$machineId</td><td>$title</td><td>$updateInfo</td>";
				echo "<td><input type='button' value='修改' onclick='gotoUpdateMachine($machineId);'></input>";
				echo "<input type='button' value='删除' onclick='deleteMachine($machineId);'></input><td>";
				echo "</tr>";
			}
			?>
		</table>
		</td>
	</tr>
</table>
</body>
</html>
